<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ page contentType="text/html; charset=utf-8"%>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>平台管理系统</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="/layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="/layuiadmin/style/admin.css" media="all">
    <link rel="stylesheet" type="text/css" href="/css/plugins/dropzone/basic.css"/>
    <link rel="stylesheet" type="text/css" href="/css/plugins/dropzone/dropzone.css"/>
    <link rel="stylesheet" type="text/css" href="/css/plugins/layui-formSelect/formSelects-v4.css"/>
    <link rel="stylesheet" type="text/css" href="/css/plat-style.css"/>
    <style>
        img{margin-left: 5px}
        tr th{text-align: center!important;}
        tr td{text-align: center!important;}
    </style>
</head>
<body>
<div class="layui-col-md12">
    <div class="layui-card">
        <div class="layui-card-body">
            <div class="layui-tab layui-tab-brief" lay-filter="test">
                <ul class="layui-tab-title">
                    <li class="layui-this" lay-id="1">&nbsp;&nbsp;&nbsp;基本设置&nbsp;&nbsp;&nbsp;</li>
                    <li lay-id="2">&nbsp;&nbsp;&nbsp;相关协议&nbsp;&nbsp;&nbsp;</li>
                    <li lay-id="3">&nbsp;&nbsp;&nbsp;购物配置&nbsp;&nbsp;&nbsp;</li>
<%--                    <li lay-id="4">&nbsp;&nbsp;&nbsp;支付配置&nbsp;&nbsp;&nbsp;</li>--%>
                    <li lay-id="5">&nbsp;&nbsp;&nbsp;基础信息配置&nbsp;&nbsp;&nbsp;</li>
                    <li lay-id="6">&nbsp;&nbsp;&nbsp;版本信息&nbsp;&nbsp;&nbsp;</li>
                </ul>
                <div class="layui-tab-content">
                    <%-- 基本设置 --%>
                    <div class="layui-tab-item layui-show" style="margin-top: 20px">
                        <form class="layui-form" id="editBaseInfoForm">
                            <input type="hidden" name="id" value="${baseInfo.id}">
                            <div class="layui-container">
                                <div class="layui-form-item">
                                    <label class="layui-col-sm1 layui-col-sm-offset1"><span class="red">*&nbsp;</span>网站名称</label>
                                    <div class="layui-col-sm4">
                                        <input type="text" name="websiteName" value="${baseInfo.websiteName}" class="layui-input"
                                               placeholder="控制在25个字以内">
                                    </div>
                                </div>
                                <div class="layui-form-item">
                                    <label class="layui-col-sm1 layui-col-sm-offset1"><span class="red">*&nbsp;</span>网站关键词</label>
                                    <div class="layui-col-sm4">
                                        <input type="text" name="websiteKey" value="${baseInfo.websiteKey}" class="layui-input"
                                               placeholder="5个左右,8汉字以内,用英文,隔开">
                                    </div>
                                </div>
                                <div class="layui-form-item">
                                    <label class="layui-col-sm1 layui-col-sm-offset1"><span class="red">*&nbsp;</span>网站描述</label>
                                    <div class="layui-col-sm4">
                                        <input type="text" name="websiteDesc" value="${baseInfo.websiteDesc}" class="layui-input"
                                               placeholder="在80个汉字，160个字符以内">
                                    </div>
                                </div>
                                <hr>
                                <div class="layui-form-item">
                                    <label class="layui-col-sm1 layuappLogoappLogoi-col-sm-offset1"><span class="red">*&nbsp;</span>网站LOGO</label>
                                    <div class="layui-col-sm3">
                                        <label for="pcLogo" class="layui-btn layui-btn-sm layui-btn-primary">PC端Logo</label>
                                        <input accept=".jpg,.png,.gif,.jpeg" type="file" style="display:none;"
                                               name="pcLogoImage" id="pcLogo" onchange="showImg(this)"/>
                                        <img id="pcImg" src="${baseInfo.pcLogo==""?' ':baseInfo.pcLogo}" width="120px" height="120px" style="margin-top: 5px" />
                                    </div>
                                    <div class="layui-col-sm3">
                                        <label for="appLogo" class="layui-btn layui-btn-sm layui-btn-primary">APP端Logo</label>
                                        <input accept=".jpg,.png,.gif,.jpeg" type="file" style="display:none;"
                                               name="appLogoImage" id="appLogo"
                                               onchange="showImg(this)"/>
                                        <img id="appImg" src="${baseInfo.appLogo==""?' ':baseInfo.appLogo}"
                                             width="120px" height="120px"/>
                                    </div>
                                </div>
                                <div class="layui-form-item">
                                    <label class="layui-col-sm1 layui-col-sm-offset1"><span class="red">*&nbsp;</span>版权</label>
                                    <div class="layui-col-sm4">
                                        <input type="text" name="copyright" value="${baseInfo.copyright}" class="layui-input" placeholder="填写版权信息">
                                    </div>
                                </div>
                                <div class="layui-form-item">
                                    <label class="layui-col-sm1 layui-col-sm-offset1"><span class="red">*&nbsp;</span>网站备案号</label>
                                    <div class="layui-col-sm4">
                                        <input type="text" name="icpVal" value="${baseInfo.icpVal}" autocomplete="off" class="layui-input" placeholder="填写网站备案号信息">
                                    </div>
                                </div>
                                <hr>
                                <div class="layui-form-item">
                                    <label class="layui-col-sm1 layui-col-sm-offset1"><span class="red">*&nbsp;</span>二维码</label>
                                    <div class="layui-col-sm3">
                                        <label for="andUrl" class="layui-btn layui-btn-sm layui-btn-primary">安卓二维码</label>
                                        <input accept=".jpg,.png,.gif,.jpeg" type="file" style="display:none;"
                                               name="andUrl" id="andUrl" onchange="showImg(this)"/>
                                        <img id="andImg" src="${baseInfo.androidQr==""?' ':baseInfo.androidQr}"
                                             width="120px" height="120px"/>
                                    </div>
                                    <div class="layui-col-sm3">
                                        <label for="iosUrl" class="layui-btn layui-btn-sm layui-btn-primary">iOS二维码</label>
                                        <input accept=".jpg,.png,.gif,.jpeg" type="file" style="display:none;"
                                               name="iosUrl" id="iosUrl" onchange="showImg(this)"/>
                                        <img id="iosImg" src="${baseInfo.iosQr==""?' ':baseInfo.iosQr}" width="120px"
                                             height="120px"/>
                                    </div>
                                    <div class="layui-col-sm3">
                                        <label for="wxUrl" class="layui-btn layui-btn-sm layui-btn-primary">微信二维码</label>
                                        <input accept=".jpg,.png,.gif,.jpeg" type="file" style="display:none;"
                                               name="wxUrl" id="wxUrl"
                                               onchange="showImg(this)"/>
                                        <img id="wxImg" src="${baseInfo.wxQr==""?' ':baseInfo.wxQr}" width="120px"
                                             height="120px"/>
                                    </div>
                                </div>
                                <hr>
                                <div class="layui-card-body" style="padding: 15px;"></div>
                                <div class="layui-form-item">
                                    <div class="layui-col-sm4 layui-col-sm-offset5">
                                        <div class="layui-footer" style="left: 0;">
                                            <button class="layui-btn" type="button" id="saveBaseInfo">保存</button>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="layui-card-body" style="padding: 15px;"></div>
                            <input type="hidden" name="tabIndex" value="1">
                        </form>
                    </div>
                    <%-- 协议部分 --%>
                    <div class="layui-tab-item">
                        <hr>
                        <div class="layui-card-body">
                            <div class="test-table-reload-btn layui-col-sm-offset10" style="margin-bottom: 10px;">
                                <button class="layui-btn addThis" type="button" style="margin-left: 10px" data-id="">新增协议</button>
                            </div>
                            <table class="layui-table">
                                <thead>
                                <tr>
                                    <th width="20%">协议标题</th>
                                    <th width="20%">协议创建时间</th>
                                    <th width="20%">操作</th>
                                </tr>
                                </thead>
                                <tbody>
                                <c:forEach items="${agreeList}" var="al">
                                    <tr class="text-c">
                                        <td>${al.title}</td>
                                        <td><fmt:formatDate value="${al.createtime}" pattern="yyyy-MM-dd HH:mm:ss"></fmt:formatDate></td>
                                        <td>
                                            <a data-id="${al.type}" data-type="editThis" class="layui-btn layui-btn-sm layui-btn-primary editThis">编辑</a>
                                        </td>
                                    </tr>
                                </c:forEach>
                                </tbody>
                            </table>
                        </div>
                    </div>
                    <%-- 购物配置 --%>
                    <div class="layui-tab-item" style="margin-top: 20px">
                        <form class="layui-form" id="shopForm">
                            <input type="hidden" name="id" value="${shop.id}">
                            <div class="layui-container">
                                <div class="layui-form-item">
                                    <label class="layui-col-sm1 layui-col-sm-offset1"><span class="red">*&nbsp;</span>自动退款时间</label>
                                    <div class="layui-col-sm4" style="margin-left: 20px">
                                        <input type="text" name="autoRefund" value="${shop.autoRefund}" class="layui-input">
                                        <label class="green">自动退款时间(单位: 天), -1表示不需要自动退款</label>
                                    </div>
                                </div>
                                <div class="layui-form-item">
                                    <label class="layui-col-sm1 layui-col-sm-offset1"><span class="red">*&nbsp;</span>自动收货时间</label>
                                    <div class="layui-col-sm4" style="margin-left: 20px">
                                        <input type="text" name="autoReceived" value="${shop.autoReceived}" class="layui-input">
                                        <label class="green">自动收货时间(单位: 天), -1表示不需要自动收货</label>
                                    </div>
                                </div>
                                <div class="layui-form-item">
                                    <label class="layui-col-sm1 layui-col-sm-offset1"><span class="red">*&nbsp;</span>自动交易完成时间</label>
                                    <div class="layui-col-sm4" style="margin-left: 20px">
                                        <input type="text" name="autoOver" value="${shop.autoOver}" class="layui-input">
                                        <label class="green">自动交易完成时间(单位: 天), -1表示不需要自动交易完成</label>
                                    </div>
                                </div>
                                <div class="layui-form-item">
                                    <label class="layui-col-sm1 layui-col-sm-offset1"><span class="red">*&nbsp;</span>自动取消订单</label>
                                    <div class="layui-col-sm4" style="margin-left: 20px">
                                        <input type="text" name="autoCancel" value="${shop.autoCancel}" class="layui-input">
                                        <label class="green">自动取消订单（单位: 分钟）</label>
                                    </div>
                                </div>
                                <hr>
                                <div class="layui-card-body" style="padding: 15px;"></div>
                                <div class="layui-form-item">
                                    <div class="layui-col-sm4 layui-col-sm-offset5">
                                        <div class="layui-footer" style="left: 0;">
                                            <button class="layui-btn" type="button" id="saveShopInfo">保存</button>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="layui-card-body" style="padding: 15px;"></div>
                            <input type="hidden" name="tabIndex" value="3">
                        </form>
                    </div>
                    <%-- 支付配置 --%>
<%--                    <div class="layui-tab-item" style="margin-top: 20px">--%>
<%--                        <form class="layui-form" id="wxInfoForm">--%>
<%--                            <div class="layui-form-item">--%>
<%--                                <label class="layui-col-sm2 layui-col-sm-offset1"><span class="red">*&nbsp;</span>微信号：</label>--%>
<%--                                <div class="layui-col-sm4">--%>
<%--                                    <input type="text" value="${wxPay.wxNum}" class="layui-input" name="wxNum">--%>
<%--                                </div>--%>
<%--                            </div>--%>
<%--                            <div class="layui-form-item">--%>
<%--                                <label class="layui-col-sm2 layui-col-sm-offset1"><span class="red">*&nbsp;</span>微信公众号名称：</label>--%>
<%--                                <div class="layui-col-sm4">--%>
<%--                                    <input type="text" value="${wxPay.wxName}" class="layui-input" name="wxName">--%>
<%--                                </div>--%>
<%--                            </div>--%>
<%--                            <div class="layui-form-item">--%>
<%--                                <label class="layui-col-sm2 layui-col-sm-offset1"><span class="red">*&nbsp;</span>微信支付APPID：</label>--%>
<%--                                <div class="layui-col-sm4">--%>
<%--                                    <input type="text" value="${wxPay.appId}" class="layui-input" name="appId">--%>
<%--                                </div>--%>
<%--                            </div>--%>
<%--                            <div class="layui-form-item">--%>
<%--                                <label class="layui-col-sm2 layui-col-sm-offset1"><span class="red">*&nbsp;</span>微信支付AppsecretKey：</label>--%>
<%--                                <div class="layui-col-sm4">--%>
<%--                                    <input type="text" value="${wxPay.appsecretKey}" class="layui-input" name="appsecretKey">--%>
<%--                                </div>--%>
<%--                            </div>--%>
<%--                            <div class="layui-form-item">--%>
<%--                                <label class="layui-col-sm2 layui-col-sm-offset1"><span class="red">*&nbsp;</span>微信支付秘钥：</label>--%>
<%--                                <div class="layui-col-sm4">--%>
<%--                                    <input type="text" value="${wxPay.keyval}" class="layui-input" name="keyval">--%>
<%--                                </div>--%>
<%--                            </div>--%>
<%--                            <div class="layui-form-item">--%>
<%--                                <label class="layui-col-sm2 layui-col-sm-offset1"><span class="red">*&nbsp;</span>APP/网页支付商户号：</label>--%>
<%--                                <div class="layui-col-sm4">--%>
<%--                                    <input type="text" value="${wxPay.mchId}" class="layui-input" name="mchId">--%>
<%--                                </div>--%>
<%--                            </div>--%>
<%--                            <div class="layui-form-item">--%>
<%--                                <label class="layui-col-sm2 layui-col-sm-offset1"><span class="red">*&nbsp;</span>APP开放平台商户号APPID：</label>--%>
<%--                                <div class="layui-col-sm4">--%>
<%--                                    <input type="text" value="${wxPay.mappId}" class="layui-input" name="mappId">--%>
<%--                                </div>--%>
<%--                            </div>--%>
<%--                            <div class="layui-form-item">--%>
<%--                                <label class="layui-col-sm2 layui-col-sm-offset1"><span class="red">*&nbsp;</span>APP开放平台对应商户号SecretKey：</label>--%>
<%--                                <div class="layui-col-sm4">--%>
<%--                                    <input type="text" value="${wxPay.mappsecretKey}" class="layui-input" name="mappsecretKey">--%>
<%--                                </div>--%>
<%--                            </div>--%>
<%--                            <div class="layui-form-item">--%>
<%--                                <label class="layui-col-sm2 layui-col-sm-offset1"><span class="red">*&nbsp;</span>微信支付网页回调地址：</label>--%>
<%--                                <div class="layui-col-sm4">--%>
<%--                                    <input type="text" value="${wxPay.returnUrl}" class="layui-input" name="returnUrl">--%>
<%--                                </div>--%>
<%--                            </div>--%>
<%--                        </form>--%>
<%--                        <hr>--%>
<%--                        <form class="form form-horizontal" id="aliInfoForm">--%>
<%--                            <input type="hidden" name="aliId" value="${aliPay.aliId}">--%>
<%--                            <div class="layui-form-item">--%>
<%--                                <label class="layui-col-sm2 layui-col-sm-offset1"><span class="red">*&nbsp;</span>支付宝商户账号：</label>--%>
<%--                                <div class="layui-col-sm4">--%>
<%--                                    <input type="text" value="${aliPay.partnerAccount}" class="layui-input"--%>
<%--                                           name="partnerAccount">--%>
<%--                                </div>--%>
<%--                            </div>--%>
<%--                            <div class="layui-form-item">--%>
<%--                                <label class="layui-col-sm2 layui-col-sm-offset1"><span class="red">*&nbsp;</span>支付宝商户号：</label>--%>
<%--                                <div class="layui-col-sm4">--%>
<%--                                    <input type="text" value="${aliPay.partner}" class="layui-input" name="partner">--%>
<%--                                </div>--%>
<%--                            </div>--%>
<%--                            <div class="layui-form-item">--%>
<%--                                <label class="layui-col-sm2 layui-col-sm-offset1"><span class="red">*&nbsp;</span>支付宝公钥：</label>--%>
<%--                                <div class="layui-col-sm4">--%>
<%--                                    <input type="text" value="${aliPay.aliPublicKey}" class="layui-input" name="aliPublicKey">--%>
<%--                                </div>--%>
<%--                            </div>--%>
<%--                            <div class="layui-form-item">--%>
<%--                                <label class="layui-col-sm2 layui-col-sm-offset1"><span class="red">*&nbsp;</span>支付宝商户私钥：</label>--%>
<%--                                <div class="layui-col-sm4">--%>
<%--                                    <input type="text" value="${aliPay.privateKey}" class="layui-input" name="privateKey">--%>
<%--                                </div>--%>
<%--                            </div>--%>
<%--                            <div class="layui-form-item">--%>
<%--                                <label class="layui-col-sm2 layui-col-sm-offset1"><span class="red">*&nbsp;</span>APP支付私钥：</label>--%>
<%--                                <div class="layui-col-sm4">--%>
<%--                                    <input type="text" value="${aliPay.aliPrivateKey}" class="layui-input" name="aliPrivateKey">--%>
<%--                                </div>--%>
<%--                            </div>--%>
<%--                            <div class="layui-form-item">--%>
<%--                                <label class="layui-col-sm2 layui-col-sm-offset1"><span class="red">*&nbsp;</span>回调域名：</label>--%>
<%--                                <div class="layui-col-sm4">--%>
<%--                                    <input type="text" value="${aliPay.returnUrl}" class="layui-input" name="returnUrl">--%>
<%--                                </div>--%>
<%--                            </div>--%>
<%--                            <div class="layui-form-item">--%>
<%--                                <label class="layui-col-sm2 layui-col-sm-offset1"><span class="red">*&nbsp;</span>Web退款编号：</label>--%>
<%--                                <div class="layui-col-sm4">--%>
<%--                                    <input type="text" value="${aliPay.refundWeb}" class="layui-input" name="refundWeb">--%>
<%--                                </div>--%>
<%--                            </div>--%>
<%--                            <div class="layui-form-item">--%>
<%--                                <label class="layui-col-sm2 layui-col-sm-offset1"><span class="red">*&nbsp;</span>App退款编号：</label>--%>
<%--                                <div class="layui-col-sm4">--%>
<%--                                    <input type="text" value="${aliPay.refundApp}" class="layui-input" name="refundApp">--%>
<%--                                </div>--%>
<%--                            </div>--%>
<%--                            <div class="layui-form-item">--%>
<%--                                <label class="layui-col-sm2 layui-col-sm-offset1"><span class="red">*&nbsp;</span>退款公钥：</label>--%>
<%--                                <div class="layui-col-sm4">--%>
<%--                                    <input type="text" value="${aliPay.refundPublicKey}" class="layui-input" name="refundPublicKey">--%>
<%--                                </div>--%>
<%--                            </div>--%>
<%--                            <div class="layui-form-item">--%>
<%--                                <label class="layui-col-sm2 layui-col-sm-offset1"><span class="red">*&nbsp;</span>退款私钥：</label>--%>
<%--                                <div class="layui-col-sm4">--%>
<%--                                    <input type="text" value="${aliPay.refundPrivateKey}" class="layui-input" name="refundPrivateKey">--%>
<%--                                </div>--%>
<%--                            </div>--%>
<%--                            <hr>--%>
<%--                        </form>--%>
<%--                        <div class="layui-form-item">--%>
<%--                            <div class="layui-col-sm4 layui-col-sm-offset4">--%>
<%--                                <div class="layui-footer" style="left: 0;">--%>
<%--                                    <button class="layui-btn" type="button" id="savePayInfo">保存</button>--%>
<%--                                </div>--%>
<%--                            </div>--%>
<%--                        </div>--%>
<%--                    </div>--%>
                    <!-- 基础配置 -->
                    <div class="layui-tab-item" style="margin-top: 20px">
                        <div class="layui-card-body">
                            <%--<div class="test-table-reload-btn layui-col-sm-offset10" style="margin-bottom: 10px;">
                                <button class="layui-btn updateParam" data-type="updateParam" type="button" style="margin-left: 5px" data-id="">新增</button>
                            </div>--%>
                            <table class="layui-table">
                                <thead>
                                <tr>
                                    <th width="25%">备注</th>
                                    <th width="10%">参数</th>
                                    <th width="20%">信息</th>
                                    <th width="5%">操作</th>
                                </tr>
                                </thead>
                                <tbody>
                                <c:forEach items="${paramList}" var="al">
                                    <tr class="text-c">
                                        <td>${al.remark}</td>
                                        <td>${al.kvalue}</td>
                                        <td>${al.otherInfo}</td>
                                        <td>
                                            <button data-id="${al.id}" data-type="updateParam" type="button"
                                                    class="layui-btn layui-btn-sm layui-btn-warm updateParam">编辑</button>
                                        </td>
                                    </tr>
                                </c:forEach>
                                </tbody>
                            </table>
                        </div>
                    </div>

                    <!-- 版本信息 -->
                    <div class="layui-tab-item" style="margin-top: 20px">
                        <div class="layui-card-body">
                            <form class="layui-form" id="editAppVersionForm">
                                <input type="hidden" name="id" value="${version.id}">
                                <div class="layui-container">
                                    <div class="layui-form-item">
                                        <label class="layui-col-sm3 layui-col-sm-offset1"><span class="red">*&nbsp;</span>安卓下载地址：</label>
                                        <div class="layui-col-sm4">
                                            <input type="text" name="androidUrl" value="${version.androidUrl}" class="layui-input"
                                                   placeholder="安卓下载地址">
                                        </div>
                                    </div>
                                    <div class="layui-form-item">
                                        <label class="layui-col-sm3 layui-col-sm-offset1"><span class="red">*&nbsp;</span>IOS应用商店上的APPID：</label>
                                        <div class="layui-col-sm4">
                                            <input type="text" name="appId" value="${version.appId}" class="layui-input">
                                        </div>
                                    </div>
                                    <div class="layui-form-item">
                                        <label class="layui-col-sm3 layui-col-sm-offset1"><span class="red">*&nbsp;</span>安卓版本(每次更新，后台版本+1)：</label>
                                        <div class="layui-col-sm4">
                                            <input type="text" name="appVersion" value="${version.appVersion}" class="layui-input">
                                        </div>
                                    </div>
                                    <div class="layui-form-item">
                                        <label class="layui-col-sm3 layui-col-sm-offset1"><span class="red">*&nbsp;</span>IOS版本(每次更新，后台版本+1)：</label>
                                        <div class="layui-col-sm4">
                                            <input type="text" name="iosVersion" value="${version.iosVersion}" class="layui-input">
                                        </div>
                                    </div>
                                    <hr>
                                    <div class="layui-card-body" style="padding: 15px;"></div>
                                    <div class="layui-form-item">
                                        <div class="layui-col-sm4 layui-col-sm-offset5">
                                            <div class="layui-footer" style="left: 0;">
                                                <button class="layui-btn" type="button" id="saveAppVersion">保存</button>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <div class="layui-card-body" style="padding: 15px;"></div>
                                <input type="hidden" name="tabIndex" value="6">
                            </form>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<input type="hidden" id="tabIndex" value="${tabIndex}">
<script src="/layuiadmin/layui/layui.js"></script>
<script type="text/javascript" src="/js/jquery/jquery.min.js"></script>
<script type="text/javascript" src="/js/jquery.form.js"></script>
<script type="text/javascript" src="/js/common.js"></script>
<script type="text/javascript" src="/js/plugins/image/previewImg.js"></script>
<script type="text/javascript" src="/js/plugins/dropzone/dropzone.js"></script>
<script type="text/javascript" src="/js/plugins/layui-formSelect/formSelects-v4.min.js"></script>
<script>
    layui.config({
        //静态资源所在路径
        base: '/layuiadmin/'
    }).extend({
        //主入口模块
        index: 'lib/index'
    }).use(['index', 'form','upload'], function(){
        var $ = layui.$, admin = layui.admin, element = layui.element, layer = layui.layer;
        //tab绑定事件，页面刷新时定位到制定的tab
        //使用的是layui的'lay-id'属性
        var tabIndex = $("#tabIndex").val();
        element.tabChange('test',tabIndex);

        var active = {
            editThis: function (id) {
                window.location.href = "/sys/agreementEdit?type="+id;
            },
            //因为要绑定tab回选
            delThis:function (id,url) {
                layer.confirm('确定删除吗？', function(){
                    $.ajax({
                        url: url,
                        data: {'id': id},
                        dataType: "json",
                        type: "post",
                        success: function (status) {
                            if (status) {
                                layer.msg('删除成功', {icon: 1});
                                setTimeout(function () {
                                    var tabIndex = 2;
                                    location.href = "/sys/baseInfo?tabIndex="+tabIndex;
                                }, 1000)
                            } else {
                                layer.msg('删除失败', {icon: 2})
                            }
                        }
                    })
                });
            },
            updateParam: function (id) {
            	layer.open({
                    title:'新增/编辑基础信息配置',
                    type: 2,
                    area: ['550px', '520px'],
                    content: '/sys/paramEdit?paramId='+id
                });
            },
            deleteParam:function (id)  {
                layer.confirm('确定删除吗？', function(){
                    $.ajax({
                        url: "/sys/deleteParam",
                        data: {'paramId': id},
                        dataType: "json",
                        type: "post",
                        success: function (status) {
                            if (status) {
                                layer.msg('删除成功', {icon: 1});
                                setTimeout(function () {
                                    var tabIndex = 5;
                                    location.href = "/sys/baseInfo?tabIndex="+tabIndex;
                                }, 1000)
                            } else {
                                layer.msg('删除失败', {icon: 2})
                            }
                        }
                    })
                });
            }
        };
        var type = 'editThis';
        $('.editThis').on('click', function(){
            var id = $(this).data('id');
            active[type] && active[type].call(this,id);
        });
        $('.addThis').on('click', function(){
            var id = $(this).data('id');
            active[type] && active[type].call(this,id);
        });
        $('.delThis').on('click',function () {
            var delType = $(this).data('type');
            var id = $(this).data('id');
            var url = "/sys/deleteAgreement";
            active[delType] && active[delType].call(this,id,url);
        });
        $('.updateParam').on('click', function(){
            var id = $(this).data('id');
            var updateType = $(this).data('type');
            active[updateType] && active[updateType].call(this,id);
        });
        $('.deleteParam').on('click', function(){
            var id = $(this).data('id');
            var deleteType = $(this).data('type');
            active[deleteType] && active[deleteType].call(this,id);
        });
    });

    $("#saveAppVersion").on('click',function(){
        $('#editAppVersionForm').ajaxSubmit({
            url: '/sys/doEditAppVersion',
            data: $('#editAppVersionForm').serialize(),
            dataType: 'json',
            success: function (data) {
                if (data.status) {
                    layer.msg(data.desc);
                    setTimeout(function () {
                        var tabIndex = $("#editAppVersionForm").find("[name='tabIndex']").val();
                        location.href = "/sys/baseInfo?tabIndex="+tabIndex;
                    }, 1000)
                } else {
                    layer.msg(data.desc);
                }
            },
            error: function () {
                layer.msg("请检查页面信息是否正确");
            }
        });
    });

    $("#saveBaseInfo").on('click', function () {
        $('#editBaseInfoForm').ajaxSubmit({
            type: 'post',
            url: '/sys/doEditBaseInfo',
            data: $('#editBaseInfoForm').serialize(),
            dataType: 'json',
            success: function (data) {
                if (data.status) {
                    layer.msg(data.desc);
                    setTimeout(function () {
                        var tabIndex = $("#editBaseInfoForm").find("[name='tabIndex']").val();
                        location.href = "/sys/baseInfo?tabIndex="+tabIndex;
                    }, 1000)
                } else {
                    layer.msg(data.desc);
                }
            },
            error: function () {
                layer.msg("请检查页面信息是否正确");
            }
        });
    })

    $("#saveShopInfo").on('click', function () {
        $('#shopForm').ajaxSubmit({
            type: 'post',
            url: '/sys/doEditShopInfo',
            data: $('#shopForm').serialize(),
            dataType: 'json',
            success: function (data) {
                if (data.status) {
                    layer.msg(data.desc);
                    setTimeout(function () {
                        var tabIndex = $("#shopForm").find("[name='tabIndex']").val();
                        location.href = "/sys/baseInfo?tabIndex="+tabIndex;
                    }, 1000)
                } else {
                    layer.msg(data.desc);
                }
            },
            error: function () {
                layer.msg("请检查页面信息是否正确");
            }
        });
    });

    // 保存微信支付配置信息
    $("#savePayInfo").on('click', function () {
        $.ajax({
            url: "/sys/doEditWxPayInfo",
            data: $('#wxInfoForm').serialize(),
            dataType: "json",
            type: "post",
            traditional: true,
            success: function (data) {
                if (data != null) {
                    if (data.status) {
                        saveAliPayInfo();
                    } else {
                        layer.msg(data.desc);
                    }
                }
            }
        });
    });

    // 保存支付宝支付配置信息
    function saveAliPayInfo() {
        $.ajax({
            url: "/sys/doEditAliPayInfo",
            data: $('#aliInfoForm').serialize(),
            dataType: "json",
            type: "post",
            traditional: true,
            success: function (data) {
                if (data.status) {
                    layer.msg(data.desc);
                    window.setTimeout(function () {
                        var tabIndex = 4;
                        location.href = "/sys/baseInfo?tabIndex="+tabIndex;
                    }, 1000);
                }else{
                    layer.msg(data.desc);
                }
            }
        });
    }
</script>
</body>
</html>